<template>
    <div id="brandIndex">
      <product-img :productImg="banner_mobile"/>
      <paragraph-intro :ParagraphIntro_title="getText('title')" :ParagraphIntro_content="brandContent"/>
      <show-concept-list v-for="(list,index) in conceptList" :key="index" :info="list"/>
      <brand-story :brandStoryInfo="brandStory"/>
      <company-news @changeScroll="changeScroll" :newsList="newsList"/>
    </div>
</template>

<script>
  import productImg from '@/components/product/productImg'
  import ParagraphIntro from '@/components/brand/ParagraphIntro'
  import brandStory from '@/components/brand/brandStory'
  import companyNews from '@/components/brand/companyNews'
  import showConceptList from '@/components/brand/showConceptList'
  export default {
        name: "brandIndex",
      data(){
          return{
            banner_mobile:'',
            brandContent:'',
            conceptList:{},
            brandStory:{},
            newsList:{},
          }
      },
    computed:{
      lang:{
        get(){
          let storageData = window.sessionStorage.getItem('lang');
            if(this.$store.state.lang!==storageData&&storageData!=='null'){
                this.$store.dispatch('toChangeLang', storageData);    //同步操作
            }
            return this.$store.getters.getLang;
        },
        set(){}
      },
    },
    methods:{
      changeScroll(){
        this.$emit('changeScroll');
      },
      getText(text){
        let str = 'brand.'+text;
        return this.$t(str);
      },
      changeCurrentPageText(route){
        //显示当前页
        let lang=this.lang;
        if(route==='/MallIndex'){
          if(lang==='en'){
            this.$store.dispatch('toChangeCurrentPageText','mall');
          }else{
            this.$store.dispatch('toChangeCurrentPageText','商城');
          }
        }
        if(route==='/brandIndex'){
          if(lang==='en'){
            this.$store.dispatch('toChangeCurrentPageText','brand');
          }else{
            this.$store.dispatch('toChangeCurrentPageText','品牌');
          }
        }
        if(route==='/CompanyProfileIndex'){
          if(lang==='en'){
            this.$store.dispatch('toChangeCurrentPageText','company profileIndex');
          }else{
            this.$store.dispatch('toChangeCurrentPageText','公司介绍');
          }
        }
        if(route==='/theNewsList'){
          if(lang==='en'){
            this.$store.dispatch('toChangeCurrentPageText','news list');
          }else{
            this.$store.dispatch('toChangeCurrentPageText','新闻');
          }
        }
        if(route==='/NewsDetails'){
          if(lang==='en'){
            this.$store.dispatch('toChangeCurrentPageText','news details');
          }else{
            this.$store.dispatch('toChangeCurrentPageText','新闻详情');
          }
        }
      },
      //获取品牌信息
      getBrand() {
        this.$store.dispatch('toChangeLoadIngVisible',true);
        let _this = this;
        this.axios.get(domain.url+'brand/api/get_brand',{
          params:{
            language:_this.lang,
          }
        })
          .then(function (response) {
            let data=response.data;
            _this.banner_mobile=data.banner_mobile;
            _this.brandContent=data.concept.content;
            _this.conceptList=data.concept.list;
            _this.brandStory=data.story;
            _this.newsList=data.news;
            _this.changeCurrentPageText('/brandIndex');
            _this.$store.dispatch('toChangeLoadIngVisible',false);
          })
          .catch(function (error) {
            console.log(error);
          });
      },
    },
      components:{
        productImg:productImg,
        ParagraphIntro:ParagraphIntro,
        brandStory:brandStory,
        companyNews:companyNews,
        showConceptList:showConceptList,
      },
    created() {
      this.getBrand();
    }
  }
</script>

<style scoped>
#brandIndex{
  color:#000000;
  background: #f5f5f5;
  width:100%;
  height:100%;
}
</style>
